/*
 *  string.cpp
 *  FrostOS
 *
 *  Created by bluechill on 12/5/09.
 *  Copyright 2009 SecurityOverride. All rights reserved.
 *
 */

#include "string.h"
namespace std {
	
	template <class T>
	basic_string<T>::basic_string(size_t n, char c)
	{
		characters = "";
		for (size_t i=0;i<=n;i++)
		{
			characters += c;
		}
	}
	
	template <class T>
	basic_string<T>::basic_string(const char* s, size_t n)
	{
		characters = "";
		for (size_t i=0;i<=n;i++)
		{
			characters += s;
		}
	}
	
	template <class T>
	bool basic_string<T>::operator== ( const basic_string<T>& lhs)
	{
		char* lhscharacters = "";
		
		for (int i=0;i<lhs.size();i++)
		{
			lhscharacters += lhs[i];
		}
		
		if (characters == lhscharacters)
		{
			return true;
		}
		else {
			return false;
		}
	}
	
	template <class T>
	bool basic_string<T>::operator== ( const char* lhs)
	{
		char* lhscharacters = "";
		for (int i=0;i<intstrlen(lhs);i++)
		{
			lhscharacters += lhs[i];
		}
		
		if (lhscharacters == characters)
		{
			return true;
		}
		else {
			return false;
		}

	}
	
	template <class T>
	bool basic_string<T>::operator!= ( const basic_string<T>& lhs)
	{
		char* lhscharacters = "";
		for (int i=0;i<lhs.size();i++)
		{
			lhscharacters += lhs[i];
		}
		
		if (characters == lhscharacters)
		{
			return false;
		}
		else {
			return true;
		}
	}
	
	template <class T>
	bool basic_string<T>::operator!= ( const char* lhs)
	{
		char* lhscharacters = "";
		for (int i=0;i<intstrlen(lhs);i++)
		{
			lhscharacters += lhs[i];
		}
		
		if (lhscharacters == characters)
		{
			return false;
		}
		else {
			return true;
		}
	}
	
	template <class T>
	basic_string<T>& basic_string<T>::operator+= ( const basic_string<T>& lhs)
	{
		for (int i=0;i<lhs.size();i++)
		{
			characters += lhs[i];
		}
		return *this;
	}
	
	template <class T>
	basic_string<T>& basic_string<T>::operator+= ( const char* s)
	{		
		characters += s;
		
		return *this;
	}
	
	template <class T>
	basic_string<T>& basic_string<T>::operator+= ( char c )
	{
		
		characters += c;
		
		return *this;
	}
	
	template <class T>
	basic_string<T> basic_string<T>::operator+ (const basic_string<T>& lhs)
	{
		basic_string<T> result = *this;
		result += lhs;
		return result;
	}
	
	template <class T>
	basic_string<T> basic_string<T>::operator+ (const char* lhs)
	{
		basic_string<T> result = *this;
		result += lhs;
		return result;
	}
	template <class T>
	basic_string<T> basic_string<T>::operator+ (char lhs)
	{
		basic_string<T> result = *this;
		result += lhs;
		return result;
	}
};